How to resolve "Could not convert JavaScript argument arg 0 [nsIDOMHTMLDivElement.appendChild]" erro

Posted by Holicreature on Stack Overflow See other posts from Stack Overflow or by Holicreature
Published on 2010-05-07T06:32:38Z Indexed on 2010/05/07 6:38 UTC
Read the original article Hit count: 304

Filed under:
|

i have a json object returned from ajax and when i alert it, it is displayed correctly and i try to add those into a unordered list and add that to a place holder div, but throws the above error..

function handleResponse() {
  if(httpa.readyState == 4){
  var response = httpa.responseText;
    //alert(response);
    if(response!='empty')
    {
      //alert(response);
      eval("prod="+response);
      var len = prod.length;
      var st = "<ul>";
      for(var cnt=0;cnt<len;cnt++)
      {
        st = st + "<li onclick='set("+prod[cnt].id+")'>"+prod[cnt].name+"</li>";  
      }      
      st = st + "</ul>";
      }
      var tt = document.getElementById('holder1');
      tt.appendChild(st); // i even tried **tt.appendChild(eval(st));**
      tt.style.display = 'block';  
    }

}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about dom